<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>钻石投票_用户信息修改</title>
    <link rel="stylesheet" href="__MCSS__/bass.css"/>
    <link rel="stylesheet" href="__CSS__/font-awesome.css"/>
    <link rel="stylesheet" href="__MCSS__/user_set.css">
</head>
<body>

<div class="user-set">
    <div class="user-main">
        <p class="user-set-tit"><span class="span1">权限管理</span><i class="fa fa-caret-right"></i><span
                class="span2">修改密码</span></p>
        <form class="layui-form">
            <div class="user-list">
                <p class="user-list-tit">用户名称：</p>
                {eq name="founder" value="1"}
                <input type="text" name="admin" value="{$username}">
                {else /}
                <input type="text" value="{$username}" disabled>
                {/eq}
            </div>
            <div class="user-list">
                <p class="user-list-tit">用户密码：</p>
                <input type="password" name="password" id="password" lay-verify="required|password"
                       placeholder="请填写新密码">
            </div>
            <div class="user-list">
                <p class="user-list-tit">确认密码：</p>
                <input type="password" name="confirm_password" id="confirm_password" lay-verify="required|confirm_pass" placeholder="确认新密码">
            </div>
            <!-- 保存按钮 -->
            <div class="lcg-btn5 user-set-btn" lay-submit lay-filter="zzcms_form">保存</div>
        </form>
    </div>

</div>
<script src="__JS__/jquery_v3.3.1.js"></script>
<script src="__JS__/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['form', 'layer', 'jquery'], function () {
        var form = layui.form,
                layer = layui.layer,
                $ = layui.$;
        //渲染表单
        form.render();

        //自定义验证规则
        form.verify({
            password: function (value) {
                if (value.length < 6 || value.length > 12) {
                    return '密码必须6到12位，且不能出现空格';
                }
            },
            confirm_pass: function (value) {
                if (value.length < 6 || value.length > 12) {
                    return '密码必须6到12位，且不能出现空格';
                }
                var repassvalue = $('#password').val();
                if (value != repassvalue) {
                    return '两次输入的密码不一致!';
                }
            },
        });
        //监听提交
        form.on('submit(zzcms_form)', function (res) {
            $.ajax({
                type: "POST",
                url: "{:url('password')}",
                data: res.field,
                success: function (msg) {
                    if (msg.code == 1) {
                        parent.location.reload();
                    } else {
                        layer.msg(msg.msg);
                    }
                }
            });
        });
    });
</script>
</body>
</html>